/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.worlds.ui.edge;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

/**
 *
 * @author Jacob
 */
public final class EImage extends EComponent{
    private BufferedImage image;
    private EActionListener actionListener;
    public EImage(BufferedImage img)
    {
        setImage(img);
    }
    public void setImage(BufferedImage img)
    {
        image = img;
        width = img.getWidth();
        height = img.getHeight();
    }
    public void setActionListener(EActionListener al)
    {
        actionListener = al;
    }
    @Override
    public void mousePressed()
    {
        if(actionListener != null)
            actionListener.actionPerformed();
    }
    @Override
    public void render(Graphics2D g)
    {
        super.render(g);
        g.drawImage(image, getX() - image.getWidth()/2, getY() - image.getHeight()/2, null);
    }
}
